﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for NhaChoThueMenuDAO
/// </summary>
public class DonViNhaChoThueDAO
{
    ConnectionDB ConDB;

    public DonViNhaChoThueDAO()
    {
        ConDB = new ConnectionDB();
    }

    public DataTable GetDonViNhaChoThue()
    {
        string sql = "SELECT * FROM T_DONVI_CTH ORDER BY ID";
        return ConDB.ExecuteQuery(sql, null);
    }

    public bool InsertDonViNhaChoThue(DonViNhaChoThue nct)
    {
        string sql = "INSERT INTO T_DONVI_CTH(Ten) VALUES(@Ten)";
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@Ten", nct.Ten);
        return ConDB.ExecuteNonQuery(sql, para);
    }

    public bool UpdateDonViNhaChoThue(DonViNhaChoThue nct)
    {
        string sql = "UPDATE T_DONVI_CTH SET Ten=@Ten WHERE ID=@ID";
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@Ten", nct.Ten);
        para[1] = new SqlParameter("@ID", nct.ID);
        return ConDB.ExecuteNonQuery(sql, para);
    }

    public bool DeleteDonViNhaChoThue(DonViNhaChoThue nct)
    {
        string sql = "DELETE FROM T_DONVI_CTH WHERE ID=@ID";
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@ID", nct.ID);
        return ConDB.ExecuteNonQuery(sql, para);
    }
}